import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const Index = () => import("../view/Index.vue");
const Main = () => import("../view/Main.vue");
const Detail = () => import("../view/Detail.vue");
const Login = () => import("../view/Login.vue");
const Register = () => import("../view/Register.vue");
const Search = () => import("../view/Search.vue");
const UserInfo = () => import("../view/UserInfo.vue");

const routes: RouteRecordRaw[] = [
  {
    path: "/login",
    component: Login,
  },
  {
    path: "/register",
    component: Register,
  },
  {
    path: "/",
    component: Index,
    children: [
      { path: "/", component: Main },
      { path: "/book/:id", component: Detail, props: true },
      { path: "/books/", component: Search, props: true },
      { path: "/books/:bookName", component: Search, props: true },
      { path: "/user/info", component: UserInfo },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export { router };
